package com.jk.controller;


import com.jk.service.LogAndRegService;
import com.jk.util.AliApi;
import com.jk.util.GetIP;
import com.jk.util.Send;
import com.jk.vo.AuthOrgInfo;
import com.jk.vo.AuthRepInfo;
import com.jk.vo.AuthUserIdcard;
import com.jk.vo.UserInfo;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("LogAndReg")
public class LogAndRegController {
    @Autowired
    private LogAndRegService logAndRegService;


    @Autowired(required = false)
   private Send send;

    @Autowired(required = false)
    private AliApi aliy;



    /*人脸比对*/
    @GetMapping("checkFace")
    public void checkFace(){
        String jsonString="{'type':0,'image_url_1':'http://jkpay.oss-cn-beijing.aliyuncs.com/CDoc/test/BDD2D635C7B24C699978387B4C5E6D17.jpg','image_url_2':'http://jkpay.oss-cn-beijing.aliyuncs.com/CDoc/test/458DBC3224D3435994F75463663DBD3D.jpg'}";
        try {
            String s = aliy.sendPost("https://dtplus-cn-shanghai.data.aliyuncs.com/face/verify", jsonString, "LTAIkn6r8pjJm8LQ", "ijz3VkDdSRWn29owBjrveWxJiiWGNQ");
            System.out.println("输出返回值"+s);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }


    /*验证用户登陆*/
    @PostMapping("userLog")
    public Map userLog(UserInfo userInfo, HttpServletRequest r){
        final String pcIp = GetIP.getIp(r);
        return logAndRegService.userLogin(userInfo,pcIp);
    }

    /*账号注册验重  个人 企业 通用*/
    /*企业注册邮箱链接跳转 合法验证*/
    @GetMapping("checkNumberOrId")
    public Integer checkNumberOrId(UserInfo userInfo){
        return logAndRegService.checkNumberOrId(userInfo);//正常链接，跳转企业注册页面
}                                                         //非法链接，跳转网站首页


    /* 注册 保存账号 账号类型 密码 支付密码 基本信息*/
    @PostMapping("insertUserLogin")
    public Map insertUserLogin(UserInfo user){
      return logAndRegService.inserUserLogin(user);
    }

    /* 注册 保存实名信息/*/

    @PostMapping("inserIdCard")
    public Integer inserIdCard(AuthUserIdcard idcard){
            idcard.setRealName("252522");
            /*send.sendMsg(idcard);*/
            return 1;
    }


    @PostMapping("inserOrgAuth")
    public Integer inserOrgAuth(AuthOrgInfo orgInfo){
       /* send.sendMsgAuthOrgInfo(orgInfo);*/
        return 1;
    }

    @PostMapping("inserRefAuth")
    public Integer inserRefAuth(AuthRepInfo repInfo){
        /*send.sendMsgAuthRep(repInfo);*/
        return 1;
    }







}
